import http from '@/utils/http'

const BASE_URL = '/sport/projectEntryGrade'

export interface ProjectEntryGradeResp {
  id: string
  projectId: string
  username: string
  teamName: string
  projectEntryId: string
  result: string
  score: string
  isEffective: string
  reason: string
  createUserString: string
  updateUserString: string
}
export interface ProjectEntryGradeDetailResp {
  id: string
  projectEntryId: string
  result: string
  score: string
  isEffective: string
  reason: string
  createTime: string
  updateTime: string
  createUser: string
  updateUser: string
  createUserString: string
  updateUserString: string
}
export interface ProjectEntryGradeQuery {
  projectId: string
  projectEntryId: string
  result: string
  score: string
  isEffective: string
  sort: Array<string>
}
export interface ProjectEntryGradePageQuery extends ProjectEntryGradeQuery, PageQuery {}

/** @desc 查询比赛成绩列表 */
export function listProjectEntryGrade(query: ProjectEntryGradePageQuery) {
  return http.get<PageRes<ProjectEntryGradeResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询还没有成绩的参赛者或队伍 */
export function listNoGrade(projectId: string) {
  return http.get<PageRes<ProjectEntryGradeResp[]>>(`${BASE_URL}/noGrade/${projectId}`)
}

/** @desc 查询比赛成绩详情 */
export function getProjectEntryGrade(id: string) {
  return http.get<ProjectEntryGradeDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增比赛成绩 */
export function addProjectEntryGrade(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改比赛成绩 */
export function updateProjectEntryGrade(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除比赛成绩 */
export function deleteProjectEntryGrade(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}

/** @desc 导出比赛成绩 */
export function exportProjectEntryGrade(query: ProjectEntryGradeQuery) {
  return http.download<any>(`${BASE_URL}/export`, query)
}
